# 体重函数

# 男性，0-100岁
def weight_male(age,c0,c1):
    if 0 <= age <= 2:
        return (3.41 + 20.1 * age) / (1 + 1.46 * age - 0.107 * age**2)
    elif 2 < age <= 20:
        return (9.86 + 0.37 * age) / (1 - 0.0789 * age + 0.00205 * age**2)
    elif 20 < age <= 100:
        return c0 - c1 * (age - 45)**2

# 女性，0-100岁
def weight_female(age,c0,c1):
    if 0 <= age <= 2:
        return (3.3 + 16.5 * age) / (1 + 1.25 * age - 0.109 * age**2)
    elif 2 < age <= 18:  # 调整为18岁
        return (8.36 + 0.725 * age) / (1 - 0.0766 * age + 0.00233 * age**2)
    elif 18 < age <= 100:
        return c0 - c1 * (age - 45)**2